{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: Logging before flag parsing goes to stderr.\n",
      "W0904 10:22:34.625125 139713067878208 deprecation.py:506] From /home/meixiao/anaconda3/envs/mx_py3/lib/python3.7/site-packages/tensorflow/python/ops/init_ops.py:1251: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Call initializer instance with the dtype argument instead of passing it to the constructor\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[[30.]\n",
      "  [50.]\n",
      "  [17.]]]\n"
     ]
    }
   ],
   "source": [
    "a = tf.get_variable(\"filter_w\", shape=[2, 2, 1], dtype=tf.float32)\n",
    "b = tf.get_variable(\"test_input\", shape=[1, 3, 2], dtype=tf.float32)\n",
    "b_assign_op = tf.assign(b, [[[1.0,2.0],[3.0,4.0],[5.0,6.0]]])\n",
    "a_assign_op = tf.assign(a, [[[1.0],[2.0]],[[3.0],[4.0]]])\n",
    "c_conv = tf.nn.conv1d(b_assign_op, a_assign_op, 1, \"SAME\")\n",
    "with tf.Session() as sess:\n",
    "    sess.run(tf.global_variables_initializer())\n",
    "    c_value = sess.run(c_conv)\n",
    "    print(c_value)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从以上测试代码看出，SAME padding，一维卷积，是从前往后的。开头之前不padding，末尾之后padding都是0。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "mx_py3",
   "language": "python",
   "name": "mx_py3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
